package persistencia.cv;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.LinkedList;

import negocio.cv.Barrio;
import negocio.cv.EstadoCivil;
import negocio.cv.Nacionalidad;

import persistence.DBManager;

public class DAOEstadoCivil implements DAOInterface {

	private DBManager manager;

	public DAOEstadoCivil(DBManager manager) {
		this.manager = manager;
	}

	@Override
	public void delete(Object b) {
		// TODO Auto-generated method stub

	}

	@Override
	public EstadoCivil get(String businessId) {
		EstadoCivil e = null;
		ResultSet rs = null;
		String query;
		int id = Integer.parseInt(businessId);
		try {
			query = "call tesis.estadocivil_get("+id+"@nombre)";
					
			rs = manager.openCallableQuery(query);
			rs.first();	
			e=new EstadoCivil(id,rs.getObject(1).toString());

		} catch (SQLException exc) {
			exc.printStackTrace();
		}
		return e;
	}

	@Override
	public LinkedList<EstadoCivil> getAll() {
		ResultSet rs = null;
		LinkedList<EstadoCivil> estados=new LinkedList<EstadoCivil>();
		EstadoCivil ec=null;
		String query;
	   
	        try {
	            query="call tesis.estadocivil_getall()";
	                   
	            rs=manager.openCallableQuery(query);  
	          
	          while(rs.next())
	          { 
	        	  ec=new EstadoCivil(rs.getInt(1),rs.getObject(2).toString());
	        	  estados.add(ec);
	          }
	        }catch(SQLException e)
	        {
	        	e.printStackTrace();
	        }
	        return estados; 
	}

	@Override
	public int insert(Object b) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void update(Object b) {
		// TODO Auto-generated method stub

	}

}
